<?php

/**
 * Description of GradosController
 *
 * @author MFerreira
 *
 * @export Modules
* @export-metadata RequiredRoles:ROLE_GRADUATE:ROLE_STUDENT
 */
class Grados extends Module {

    public function index() {
        $student = $this->model->students->GetById($this->currentUser->getName());
        if ($student->getEstadoEstudiante() == 1) {
            $this->assign("action", $this->route->action("update"));
            $this->assign("Estudiante", $student);
            $this->assign("options", array(
                0 => "Viudo",
                1 => "Uni&oacute;n Libre",
                2 => "Religioso",
                3 => "Separado",
                4 => "Divorciado",
                5 => "Casado",
                7 => "Soltero",
            ));
            $this->display("Index");
        } else {
            $this->display("error");
        }
    }

    public function update() {

        $student = $this->model->students->GetById($this->currentUser->getName());

        if ($this->request->submitted()) {
            $student->setNombres($this->request->post("Nombres"));
            $student->setApellidos($this->request->post("Apellidos"));

            $DatosCorreo = &$student->getDatosCorreo();
            $DatosCorreo->setDireccion($this->request->post("Direccion"));
            $DatosCorreo->setTelefono($this->request->post("Telefono"));

            $student->setEmail($this->request->post("Email"));
            $student->setEstadoCivil($this->request->post("EstadoCivil"));

            $this->model->students->Update($student);
            $this->addMessage(new Message("Sus datos personales han sido actualizados.", "", Message::SUCCESS));
        }
        $this->assign("DocumentosPendientes", $this->model->pendingDocuments->GetDocumentosPendientes($this->currentUser->getName()));
        $this->assign("student", $student);

        $this->addMessage(new Message("Estos son los documentos que le faltan.", "", Message::WARNING));
        $this->display();
    }

}

?>
